Next | Prev | Up | Top | Contents | Index
Making a CPU Nonpreemptive
After a CPU has been isolated, you can turn off the dispatching "tick" for that CPU (see "Tick Interrupts"). This eliminates the last source of overhead interrupts for that CPU. It also ends preemptive process scheduling for that CPU. This means that the process now running will continue to run until
- it gives up control voluntarily by blocking on a semaphore or lock, requesting I/O, or calling sginap()
- it calls a system function and, when the kernel is ready to return from the system function, a process of higher priority is ready to run
Some effects of this change within the specified CPU include the following:
- IRIX will no longer age degrading priorities. Priority ageing is done on clock tick interrupts.
- IRIX will no longer preempt a low-priority process when a high-priority process becomes runnable, except when the low-priority process calls a system function.
- Signals (other than SIGALARM) can only be delivered after I/O interrupts or on return from system calls. This can extend the latency of signal delivery.
Normally an isolated CPU runs only a few, related, time-critical processes that have equal priorities, and that coordinate their use of the CPU through semaphores or locks. When this is the case, the loss of preemptive scheduling is outweighed by the benefit of removing the overhead and unpredictability of interrupts.
To make a CPU nonpreemptive you can use mpadmin. For example, to isolate CPU 3 and make it nonpreemptive, you can use
mpadmin -I 3
mpadmin -D 3
The equivalent operation from within a program uses sysmp() as shown in Example 6-12 (see the sysmp(2) reference page).
Example 6-12 : Making a CPU nonpreemptive
#include <sys/sysmp.h>
int stopTimeSlicingOn(int cpu)
{
int ret = sysmp(MP_NONPREEMPTIVE,cpu);
if (-1 == ret) perror("sysmp(MP_NONPREEMPTIVE)");
return ret;
}
You reverse the operation with sysmp(MP_PREEMPTIVE) or with mpadmin -C.
Next | Prev | Up | Top | Contents | Index